package com.bootdo.mq;

import java.util.Date;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSONObject;
import com.bootdo.common.config.Constant;
import com.bootdo.common.utils.DateUtils;

/**
 * @Desc 统一推送排队信息
 * @date 2020/4/5
 *
 */
@Component
public class SendSortUtil {

    private static Logger logger = LoggerFactory.getLogger(SendSortUtil.class);

    @Autowired
    private RabbitUtil rabbitUtil;

    public void sendMsg(Set<Integer> set) {
        for (Integer type : set){
            sendMsg(type);
        }
    }

    public void sendMsg(Integer type) {
        logger.info("========进入发送排队信息，即将发送通道编号为======>" + type);
        JSONObject object = new JSONObject();
        object.put("code",1);
        object.put("date", DateUtils.format(new Date(),DateUtils.DATE_TIME_PATTERN));
        object.put("payType", type);
        rabbitUtil.sendToQueue(Constant.CHANG_SORT, object.toJSONString());
    }
}
